package com.atguigu.gmall.publisher.mapper;

import com.atguigu.gmall.publisher.bean.TestCourseBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TestCourseMapper {
    @Select("select\n" +
            "    course_id courseId,\n" +
            "    sum(userCt) userCount,\n" +
            "    sum(scoreCt)/sum(userCt) avgScore,\n" +
            "    sum(durationCt)/sum(userCt) avgTime\n" +
            "from dws_test_course_count_window\n" +
            "where toYYYYMMDD(stt) = #{date}\n" +
            "group by course_id,toYYYYMMDD(stt);")
    List<TestCourseBean> selectTestCourseBean(@Param(value = "date")Integer date);

}
